* REPLICATION WITH EXTENDED BNOS *
* 1. get extended set of BNOs --> bnoSext_merge.dta
use "$out_HS/bno_fekvo_anon_t.dta", clear
keep anon t fekvo_bno
duplicates drop
gen bno_flagSext=.
foreach x in S03 S13 S23 S33 ///
	S40 S41 S42 S43 S44 S45 S46 S49 ///
	S50 S51 S52 S53 S54 S55 S56 S59 ///
	S60 S61 S62 S63 S64 S65 S66 S69 ///
	S70 S71 S72 S73 S74 S75 S76 S79 ///
	S80 S81 S82 S83 S84 S85 S86 S89 ///
	S90 S91 S92 S93 S94 S95 S96 S99 ///
  {
	gen BNO`x' = .
	replace bno_flagSext = 1 if fekvo_bno=="`x'" 
	replace BNO`x' = 1 if fekvo_bno=="`x'" 
	}
	
egen max_bnoSext = max(bno_flagSext), by(anon t)
foreach var of varlist BNO* {
	egen max_`var' = max(`var'), by(anon t)
	}
	
keep anon t max_bnoSext max_BNO*
duplicates drop anon t, force
sort anon t
egen num_bnoSext = rowtotal(max_BNO*)

lab var 	max_BNOS03	"Dislocation and sprain of joints and ligaments of head	"
lab var 	max_BNOS13	"Dislocation and sprain of joints and ligaments at neck level	"
lab var 	max_BNOS23	"Dislocation and sprain of joints and ligaments of thorax	"
lab var 	max_BNOS33	"Dislocation and sprain of joints and ligaments of lumbar spine and pelvis	"
lab var 	max_BNOS40	"Superficial injury of shoulder and upper arm	"
lab var 	max_BNOS41	"Open wound of shoulder and upper arm	"
lab var 	max_BNOS42	"Fracture of shoulder and upper arm	"
lab var 	max_BNOS43	"Dislocation and sprain of joints and ligaments of shoulder girdle	"
lab var 	max_BNOS44	"Injury of nerves at shoulder and upper arm level	"
lab var 	max_BNOS45	"Injury of blood vessels at shoulder and upper arm level	"
lab var 	max_BNOS46	"Injury of muscle, fascia and tendon at shoulder and upper arm level	"
lab var 	max_BNOS49	"Other and unspecified injuries of shoulder and upper arm	"
lab var 	max_BNOS50	"Superficial injury of elbow and forearm	"
lab var 	max_BNOS51	"Open wound of elbow and forearm	"
lab var 	max_BNOS52	"Fracture of forearm	"
lab var 	max_BNOS53	"Dislocation and sprain of joints and ligaments of elbow	"
lab var 	max_BNOS54	"Injury of nerves at forearm level	"
lab var 	max_BNOS55	"Injury of blood vessels at forearm level	"
lab var 	max_BNOS56	"Injury of muscle, fascia and tendon at forearm level	"
lab var 	max_BNOS59	"Other and unspecified injuries of elbow and forearm	"
lab var 	max_BNOS60	"Superficial injury of wrist, hand and fingers	"
lab var 	max_BNOS61	"Open wound of wrist, hand and fingers	"
lab var 	max_BNOS62	"Fracture at wrist and hand level	"
lab var 	max_BNOS63	"Dislocation and sprain of joints and ligaments at wrist and hand level	"
lab var 	max_BNOS64	"Injury of nerves at wrist and hand level	"
lab var 	max_BNOS65	"Injury of blood vessels at wrist and hand level	"
lab var 	max_BNOS66	"Injury of muscle, fascia and tendon at wrist and hand level	"
lab var 	max_BNOS69	"Other and unspecified injuries of wrist, hand and finger(s)	"
lab var 	max_BNOS70	"Superficial injury of hip and thigh	"
lab var 	max_BNOS71	"Open wound of hip and thigh	"
lab var 	max_BNOS72	"Fracture of femur	"
lab var 	max_BNOS73	"Dislocation and sprain of joint and ligaments of hip	"
lab var 	max_BNOS74	"Injury of nerves at hip and thigh level	"
lab var 	max_BNOS75	"Injury of blood vessels at hip and thigh level	"
lab var 	max_BNOS76	"Injury of muscle, fascia and tendon at hip and thigh level	"
lab var 	max_BNOS79	"Other and unspecified injuries of hip and thigh	"
lab var 	max_BNOS80	"Superficial injury of knee and lower leg	"
lab var 	max_BNOS81	"Open wound of knee and lower leg	"
lab var 	max_BNOS82	"Fracture of lower leg, including ankle	"
lab var 	max_BNOS83	"Dislocation and sprain of joints and ligaments of knee	"
lab var 	max_BNOS84	"Injury of nerves at lower leg level	"
lab var 	max_BNOS85	"Injury of blood vessels at lower leg level	"
lab var 	max_BNOS86	"Injury of muscle, fascia and tendon at lower leg level	"
lab var 	max_BNOS89	"Other and unspecified injuries of lower leg	"
lab var 	max_BNOS90	"Superficial injury of ankle, foot and toes	"
lab var 	max_BNOS91	"Open wound of ankle, foot and toes	"
lab var 	max_BNOS92	"Fracture of foot and toe, except ankle	"
lab var 	max_BNOS93	"Dislocation and sprain of joints and ligaments at ankle, foot and toe level	"
lab var 	max_BNOS94	"Injury of nerves at ankle and foot level	"
lab var 	max_BNOS95	"Injury of blood vessels at ankle and foot level	"
lab var 	max_BNOS96	"Injury of muscle and tendon at ankle and foot level	"
lab var 	max_BNOS99	"Other and unspecified injuries of ankle and foot	"

foreach x in S03 S13 S23 S33 ///
	S40 S41 S42 S43 S44 S45 S46 S49 ///
	S50 S51 S52 S53 S54 S55 S56 S59 ///
	S60 S61 S62 S63 S64 S65 S66 S69 ///
	S70 S71 S72 S73 S74 S75 S76 S79 ///
	S80 S81 S82 S83 S84 S85 S86 S89 ///
	S90 S91 S92 S93 S94 S95 S96 S99 /// 
	{
		rename max_BNO`x' BNO`x'
		}
		
lab var num_bnoSext "# of bnoSext shocks"

save "$out/bnoSext_merge.dta", replace
